package com.ytc.position.service.Impl;

import com.ytc.company.model.Company;
import com.ytc.company.service.CompanyService;
import com.ytc.position.mapper.PositionMapper;
import com.ytc.position.model.Position;
import com.ytc.position.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PositionServiceImpl implements PositionService {

    @Autowired
    private PositionMapper positionMapper;
    @Autowired
    private CompanyService companyService;

    @Override
    public void addPosition(Position position){
        Company company = companyService.getCompany(position.getUserId());
        position.setCompanyId(company.getCompanyId());
        positionMapper.addPosition(position);
    }

    @Override
    public List<Position> getPosition(Integer userId){
        return positionMapper.getPosition(userId);
    }

    @Override
    public void updatePosition(Position position){
        positionMapper.updatePosition(position);
    }


    @Override
    public void deletePosition(Integer positionId){
        positionMapper.deletePosition(positionId);
    }

    @Override
    public Position get(Integer positionId){
        return positionMapper.get(positionId);
    }
}
